import request from '../util/request'

const baseUrl = process.env.NODE_ENV === 'production' ? '' : '/vehicleMap'

export function batchChange(multipleSelection, status , type ,price) {
    let ids = new Array();
    for(let i=0;i<multipleSelection.length;i++){
        ids[i] = multipleSelection[i].lockId
    }
    const data = {
        ids,
        price,
        status,
        type
    }
    return request({
        url:baseUrl+ '/lclock',
        method: 'put',
        data
    })
}

export function loadStatus(){
    return request({
        url:baseUrl+ '/lclock/constant/status',
        method: 'get'
    });
}

export function loadType(){
    return request({
        url:baseUrl+ '/lclock/constant/type',
        method: 'get'
    });
}

export function rm(multipleSelection){
    let ids = new Array();
    for(let i=0;i<multipleSelection.length;i++){
        ids[i] = multipleSelection[i].lockId
    }
    return request({
        url:baseUrl+ '/lclock',
        method: 'delete',
        data: ids
    });
}

export function addLockApi(form){
    return request({
        url:baseUrl+"/lclock",
        method:"post",
        data: form
    });
}

 
export function getNobindCharger(areaId){
    return request({
        url:baseUrl+ "/lccharger/getNobindCharger?areaId=" + areaId,
        method: "get"
    });
}

export function bindChargerApi(lockId, chargerId){
    return request({
        url:baseUrl+ "/lclock",
        method: "put",
        data: {
            id: lockId,
            battery: chargerId
        }
    });
}


export function loadLocksApi(params){
    return  request({
        url: baseUrl+ "/lclock",
        methods: "get",
        params:params
      });
}

export function loadLocksListApi(params){
    return  request({
        url: baseUrl+ "/lclock/list",
        methods: "get",
        params:params
      });
}





